<?php
if (!defined('IN_VANILLA')) exit();
$cm = $this->Context->ObjectFactory->NewContextObject($this->Context, 'CategoryManager');
$CategoryData = $cm->GetCategories(0, 1);
$cs = $this->Context->ObjectFactory->NewObject($this->Context, 'Select');
$cs->Name = 'CategoryID';
$cs->CssClass = 'CategorySelect';
$cat = $this->Context->ObjectFactory->NewObject($this->Context, 'Category');
$LastBlocked = -1;
while ($Row = $this->Context->Database->GetRow($CategoryData)) {
	$cat->Clear();
	$cat->GetPropertiesFromDataSet($Row);
	if ($cat->Blocked != $LastBlocked && $LastBlocked != -1) {
		$cs->AddOption("-1", "---", " disabled=\"true\"");
	}
	$cs->AddOption($cat->CategoryID, $cat->Name);
	$LastBlocked = $cat->Blocked;
}
echo '<div id="Form" class="StartDiscussion">
   <fieldset>'
      .$this->Get_Warnings()
      .$this->Get_PostBackForm('frmPostDiscussion', 'post', 'extension.php?PostBackAction=StartDiscAsMod')
      .'<ul>';
   if ($this->Context->Configuration['USE_CATEGORIES']) {
      $this->CallDelegate('DiscussionForm_PreCategoryRender');
      $cs->Attributes = ' id="ddCategories"';
      echo '<li>
         <label for="ddCategories">'.$this->Context->GetDefinition('SelectDiscussionCategory').'</label>
         '.$cs->Get()
      .'</li>';
   } else {
      echo '<input type="hidden" name="CategoryID" value="'.$cs->aOptions[0]['IdValue'].'" />';
   }
   $this->CallDelegate('DiscussionForm_PreTopicRender');
   echo '<li>
      <label for="txtTopic">'.$this->Context->GetDefinition('EnterYourDiscussionTopic').'</label>
      <input id="txtTopic" type="text" name="Name" class="DiscussionBox" maxlength="100" value="" />
   </li>';
	
	echo '<li>
	<label>Make Sticky</label>
	<input type="checkbox"  id="newSticky" value="1" name="Sticky"/>
	<label>Make Close</label>
	<input type="checkbox"  id="newClose" value="1" name="Close"/>
	</li>';

   $this->CallDelegate('DiscussionForm_PreCommentRender');
   echo '<li>
      <label for="CommentBox">
         <a href="./" id="CommentBoxController" onclick="'
            ."ToggleCommentBox('".$this->Context->Configuration['WEB_ROOT']."ajax/switch.php', '".$this->Context->GetDefinition('SmallInput')."', '".$this->Context->GetDefinition('BigInput')."'); return false;".'">'.$this->Context->GetDefinition($this->Context->Session->User->Preference('ShowLargeCommentBox')?'SmallInput':'BigInput').'</a>';
				
				$this->CallDelegate('DiscussionForm_PostCommentToggle');	
					
				echo $this->Context->GetDefinition('EnterYourComments').'
      </label>
      <textarea name="Body" class="'
      .($this->Context->Session->User->Preference('ShowLargeCommentBox') ? 'LargeCommentBox' : 'SmallCommentBox')
      .'" id="CommentBox" rows="10" cols="85"'.$this->DiscussionFormAttributes.'></textarea>
   </li></ul>';
   
   $this->CallDelegate('DiscussionForm_PreButtonsRender');
   
   echo '<div class="Submit">
      <input type="submit" name="btnSave" value="'.$this->Context->GetDefinition('StartYourDiscussion').'" class="Button SubmitButton StartDiscussionButton" onclick="'
      ."Wait(this, '".$this->Context->GetDefinition('Wait')."');"
      .'"/>';
      $this->CallDelegate('DiscussionForm_PostSubmitRender');
      echo '<a href="'.(!$this->IsPostBack?'javascript:history.back();':'./').'" class="CancelButton">'.$this->Context->GetDefinition('Cancel').'</a>
   </div>';
   
   $this->CallDelegate('DiscussionForm_PostButtonsRender');
   
   echo'</form>
   </fieldset>
</div>';
?>